//eslint-disable
import { Button } from "antd";
import { ButtonGroup } from './index';
// import ThemeContext from './ThemeContext';
// import { useContext } from 'react';
import { connect } from 'react-redux'
const ChildTwo = (props) => {
	const { sup, opp, supTian, oppTian } = props
	return (
		<ButtonGroup>
			<Button type="primary" onClick={() => sup()}>支持</Button>
			<Button danger onClick={() => opp()}>反对</Button>
			<Button type="primary" onClick={() => supTian()}>喜欢甜甜</Button>
			<Button danger onClick={() => oppTian()}>不喜欢甜甜</Button>
		</ButtonGroup>
	);
}
const delay = (time) => {
	return new Promise((resolve) => {
		setTimeout(() => {
			resolve()
		}, time)
	})
}

export default connect(null, {
	sup: () => ({ type: 'SUP' }),
	opp: () => ({ type: 'OPP' }),
	supTian: async () => {
		await delay(1000)
		return { type: 'SUP_TIAN' }
	},
	oppTian: () => async (dispatch) => {
		await delay(1000)
		dispatch({ type: 'OPP_TIAN' })
	}
})(ChildTwo)